﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Sector7.Restaurant.APs.ForeStation.Controls;
using Sector7.Restaurant.Biz;
using Sector7.Framework.Core;

namespace Sector7.Restaurant.APs.ForeStation
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void SwitchModule(UserControl module)
        {
            grdMain.Children.Clear();
            grdMain.Children.Add(module);
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Senvironments.MainWindow = this;

            //var splashWindow = new Sector7.Restaurant.Modules.SYST.Windows.SplashWindow();
            //splashWindow.LoadCompleted += new EventHandler(SplashWindow_LoadCompleted);

            //SwitchModule(splashWindow);

            var loginSystem = new Sector7.Restaurant.Modules.SYST.Windows.LoginWindow();
            loginSystem.LoginSuccess += new EventHandler(loginSystem_LoginSuccess);

            SwitchModule(loginSystem);
        }

        private void SplashWindow_LoadCompleted(object sender, EventArgs e)
        {
            var loginSystem = new Sector7.Restaurant.Modules.SYST.Windows.LoginWindow();
            loginSystem.LoginSuccess += new EventHandler(loginSystem_LoginSuccess);

            SwitchModule(loginSystem);
        }

        private void loginSystem_LoginSuccess(object sender, EventArgs e)
        {
            MainFrame mainFrame = new MainFrame();

            SwitchModule(mainFrame);
        }
    }
}
